<template>
  <div style="width:100wh;height:100vh" class="example">
    <a-spin size="large" :spinning="spinning" v-if="spinning" />
    <div style="font-Size:18px" v-else>用户未注册，请联系管理员</div>
    <!-- 授权页面 -->
  </div>
</template>

<script>
import { logout } from '@/api/loginout'
import { getUrlParams } from '@/utils/mUtils'

import { mapActions, mapGetters } from 'vuex'
import axios from '@/utils/request'

export default {
  data() {
    return {
      ticket: getUrlParams().ticket,
      role: '',
      serviceUrl: getUrlParams().serviceUrl,
      spinning: true
    }
  },
  mounted() {
    if (this.ticket) {
      this.getTickerLogin()
    } else {
      // console.log()

      top.window.location =
        process.env.VUE_APP_CAS_URL + '/login?service=' + encodeURIComponent(this.$store.state.appPublicUrl)
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  methods: {
    ...mapActions(['getTicker']),

    async getTickerLogin() {
      const result = await this.getTicker({ ticket: this.ticket })
      if (result.code == '200') {
        window.location.replace(window.location.origin + window.location.pathname + '#/aaa')
      } else {
        this.spinning = false
        setTimeout(() => {
          logout({}).then((res) => {
            this.$message.destroy()
            this.$message.success('退出成功')
            top.window.location =
              process.env.VUE_APP_CAS_URL + '/logout?service=' + encodeURIComponent(this.$store.state.appPublicUrl)
          })
        }, 2000)
      }
    }
  }
}
</script>

<style scoped>
.example {
  /* text-align: center; */
  background: rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
